bpara <- function(a,b) {
  a[is.na(a)] <- 0
  a[is.null(a)] <- 0
  a[a<0] <- 0
  b[is.na(b)] <- 0
  b[is.null(b)] <- 0
  b[b<0] <- 0
  c <- c(1:length(a))
  d <- c(1:length(b))
  dec <- which(a==0)
  ded <- which(b==0)
  if (length(dec)>0) {
    c <- log(c[-dec])
    a <- log(a[-dec])
  } else {
    c <- log(c)
    a <- log(a)
  }
  if (length(ded)>0) {
     b <- log(b[-ded])
     d <- log(d[-ded])
   }else{
    b <- log(b)
    d <- log(d)
  }
  lma <- lm(a~c)
  alma <- summary(lma)$coefficients
  lmb <- lm(b~d)
  blmb <- summary(lmb)$coefficients
  if (alma[2,1]<0 & blmb[2.1]<0)
      return(max(alma[2,1],blmb[2,1]))
    else
      return(min(alma[2,1],blmb[2,1]))
}

